import { constantMenus } from '@/router/modules'
import { ascending } from '@/router/utils'
const state = {
  // 静态路由生成的菜单
  constantMenus,
  // 整体路由生成的菜单（静态、动态）
  wholeMenus: [],
  buttonAuth: [],
  // 缓存页面keepAlive
  cachePageList: []
}
const mutations = {
  
}

const actions = {
  // 获取异步路由菜单
  // asyncActionRoutes(routes) {
  //   if (this.wholeMenus.length > 0) return
  //   this.wholeMenus = filterTree(
  //     ascending(this.constantMenus.concat(routes))
  //   );

  //   const getButtonAuth = (arrRoutes) => {
  //     if (!arrRoutes || !arrRoutes.length) return
  //     arrRoutes.forEach((v) => {
  //       if (v.meta && v.meta.authority) {
  //         this.buttonAuth.push(...v.meta.authority)
  //       }
  //       if (v.children) {
  //         getButtonAuth(v.children)
  //       }
  //     })
  //   }

  //   getButtonAuth(this.wholeMenus)
  // }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
